{ "cells": [ { "cell_type": "markdown", "id": "fe7ed8e1-11dd-438e-ae6b-5bc701b0d75e", "metadata": { "tags": [] }, "source": [ "# Example use case: Binary black hole systems\n", "In this notebook we will set up binary systems to find binary black hole systems. We will make use of the event based logs to find out whether a system has become a BBH and to store the summary of their evolution.\n", "\n", "We run individual binary systems so we can play around with the input settings and see how that affects the formation of the BHBH system. There are other, more appropriate, ways to find populations of binary black hole systems. A good start for that is setting up a custom logging code and a parse function, and then run a grid of systems. " ] }, { "cell_type": "code", "execution_count": 1, "id": "de02d59d-c3fc-41fb-af3d-09d603f5c159", "metadata": {}, "outputs": [], "source": [ "import os\n", "import json\n", "from binarycpython.utils.functions import temp_dir, output_lines\n", "from binarycpython.utils.run_system_wrapper import run_system\n", "from binarycpython import Population\n", "TMP_DIR = temp_dir(\"notebooks\", \"notebook_BHBH\", clean_path=True)\n", "EVENT_TYPE_INDEX = 3\n", "VERBOSITY = 0" ] }, { "cell_type": "markdown", "id": "18b863d5-7093-4211-af00-017ac234b24f", "metadata": {}, "source": [ "To run a system we can use the `run_system` function, which can parse function arguments for binary_c and will run a system. We will start with this but later we will use the `evolve_single` function from the Population object." ] }, { "cell_type": "code", "execution_count": 2, "id": "1ee7d75d-5399-488c-8cac-ac09f2c9ae8f", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " TIME M1/M☉ M2/M☉ st1 st2 SEP/R☉ PER ECC R1/ROL1 R2/ROL2 TYPE \n", "RANDOM_SEED=13963 RANDOM_COUNT=0\n", " 0.0000 60.000 40.000 MS MS 19.536 1 0.00 1.503 1.384 \"INITIAL \"\n", " 0.0000 60.000 40.000 MS MS 19.536 1 0.00 1.503 1.384 Contact reached R/RL = 1.50329 1.38448, st 1 1, \"Contact because R>RL\"\n", " 0.0000 90.000 0.000 MS γ -1 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", " 0.0000 90.000 0.000 MS γ -1 -1 -1.00 0.000 0.000 \"BEG_RCHE 1>2\"\n", " 0.0000 90.000 0.000 MS γ -1 -1 -1.00 0.000 0.000 \"COALESCE\"\n", " 0.0000 90.000 0.000 MS γ -1 -1 -1.00 0.000 0.000 \"END_RCHE 1!>2\"\n", " 6.6996 26.531 0.000 HG γ -1 -1 -1.00 0.000 0.000 \"OFF_MS\"\n", " 6.6996 26.531 0.000 HG γ -1 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", " 6.7093 26.469 0.000 CHeB γ -1 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", " 7.2750 9.883 0.000 HeMS γ -1 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", " 7.5818 7.328 0.000 HeHG γ -1 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", " 7.6220 2.909 0.000 BH γ -1 -1 -1.00 0.000 0.000 Randbuf=13963 - Mers(0)=0.0323703 - Mers(1)=0.973329 - Mers(2)=0.592129 - Mers(3)=0.0260156 \n", " 7.6220 2.909 0.000 BH γ -1 -1 -1.00 0.000 0.000 SN kick Ib/c (SN type 13 13, pre-explosion M=6.92349 Mc\"CO\"=5.31476 stellar_type=8 Eexp=1 foe vexp=5004.45 km/s) -> kick 1(190) vk=255.754 vr=0 omega=0.163461 phi=0.185317 -> vn=255.754 ; final sep 0 ecc -1 (random count 0) - Runaway v=(252.345,40.9072,7.66879) |v|=255.754 : companion v=(0,0,0), |v|=0 ; \n", " 7.6220 2.909 0.000 BH γ -1 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", " 7.6220 2.909 0.000 BH γ -1 -1 -1.00 0.000 0.000 \"SN\"\n", " 15000.0000 2.909 0.000 BH γ -1 -1 -1.00 0.000 0.000 \"MAX_TIME\"\n", "\n" ] } ], "source": [ "# set filename\n", "log_filename = os.path.join(TMP_DIR, \"log_file.txt\")\n", "\n", "# Run via run_system\n", "output = run_system(M_1=60, \n", " M_2=40,\n", " orbital_period=1,\n", " BH_prescription='BH_BELCZYNSKI',\n", " log_filename=log_filename, \n", " wind_mass_loss='WIND_ALGORITHM_BINARY_C_2020',\n", " clean_log='True', # removes log formatting \n", " log_period_unit='day', # sets the orbital periods in the log output to days\n", " api_log_filename_prefix=TMP_DIR)\n", "\n", "# Readout the contents\n", "with open(log_filename, 'r') as f:\n", " print(f.read())" ] }, { "cell_type": "markdown", "id": "c3115ee6-310a-4b7b-84cf-1cb777d33ffb", "metadata": {}, "source": [ "From the output of this file we can see that the stellar types (K1, K2) are not entirely what we are looking for. One of them is γ, short for \"massless remnant\" i.e. no star any more, which means the stars must have merged to make a single star. To prevent this, we can star the system with a wider initial orbit, so that the stars do not interact (except by a little wind accretion)." ] }, { "cell_type": "code", "execution_count": 3, "id": "08f93e25-92bd-4ebc-a476-5d3c7f2f3bc7", "metadata": { "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " TIME M1/M☉ M2/M☉ st1 st2 SEP/R☉ PER ECC R1/ROL1 R2/ROL2 TYPE \n", "RANDOM_SEED=76943 RANDOM_COUNT=0\n", " 0.0000 60.000 40.000 MS MS 3101.2 2e+03 0.00 0.009 0.009 \"INITIAL \"\n", " 0.0000 60.000 40.000 MS MS 3101.2 2e+03 0.00 0.009 0.009 \"BEG_SYMB\"\n", " 4.3578 42.087 35.930 MS MS 3970.7 3.28e+03 0.00 0.023 0.014 \"Start tidal lock 1\"\n", " 4.3937 41.620 35.893 MS MS 3996.4 3.32e+03 0.00 0.023 0.014 \"End tidal lock 1\"\n", " 6.4207 27.619 27.607 MS MS 5602.5 6.53e+03 0.00 0.013 0.013 \"Start tidal lock 2\"\n", " 6.5391 27.162 27.156 MS MS 5695.9 6.75e+03 0.00 0.012 0.012 \"End tidal lock 2\"\n", " 6.6477 26.762 26.731 HG MS 5791.6 6.98e+03 0.00 0.010 0.011 \"TYPE_CHNGE\"\n", " 6.6550 26.729 26.728 HG MS 5794.4 6.99e+03 0.00 0.203 0.010 \"Start tidal lock 2\"\n", " 6.6552 26.727 26.728 HG MS 5794.6 6.99e+03 0.00 0.225 0.010 \"q-inv\"\n", " 6.6553 26.726 26.728 HG HG 5795.4 6.99e+03 0.00 0.231 0.010 \"OFF_MS\"\n", " 6.6553 26.726 26.728 HG HG 5795.4 6.99e+03 0.00 0.231 0.010 \"TYPE_CHNGE\"\n", " 6.6553 26.726 26.728 HG HG 5795.4 6.99e+03 0.00 0.231 0.010 \"End tidal lock 2\"\n", " 6.6556 26.722 26.728 HG HG 5796 6.99e+03 0.00 0.266 0.011 \"Start tidal lock 2\"\n", " 6.6559 26.717 26.727 HG HG 5796.5 6.99e+03 0.00 0.302 0.012 \"End tidal lock 2\"\n", " 6.6573 26.690 26.724 CHeB HG 5798.6 7e+03 0.00 0.546 0.023 \"TYPE_CHNGE\"\n", " 6.6649 26.505 26.682 CHeB CHeB 5812 7.04e+03 0.00 0.548 0.543 \"TYPE_CHNGE\"\n", " 7.2666 10.177 10.469 CHeB CHeB 8831.5 2.11e+04 0.00 0.000 0.458 \"END_SYMB\"\n", " 7.2673 10.171 10.449 HeMS CHeB 8840.7 2.12e+04 0.00 0.000 0.453 \"TYPE_CHNGE\"\n", " 7.2733 10.113 10.271 HeMS CHeB 8920.7 2.16e+04 0.00 0.000 0.263 \"BEG_SYMB\"\n", " 7.2804 10.031 10.162 HeMS HeMS 8982.4 2.19e+04 0.00 0.000 0.000 \"TYPE_CHNGE\"\n", " 7.4927 7.910 7.993 HeHG HeMS 11436 3.55e+04 0.00 0.000 0.000 \"TYPE_CHNGE\"\n", " 7.4988 7.854 7.943 HeHG HeHG 11513 3.6e+04 0.00 0.000 0.000 \"TYPE_CHNGE\"\n", " 7.5285 3.966 7.612 BH HeHG -23.473 -1 -1.00 0.000 0.000 Randbuf=76943 - Mers(0)=0.667522 - Mers(1)=0.671034 - Mers(2)=0.473751 - Mers(3)=0.362148 - Mers(4)=0.592519 \n", " 7.5285 3.966 7.612 BH HeHG -23.473 -1 -1.00 0.000 0.000 SN kick Ib/c (SN type 13 13, pre-explosion M=7.49449 Mc\"CO\"=5.76446 stellar_type=8 Eexp=1 foe vexp=5338.47 km/s) -> kick 1(190) vk=320.854 vr=15.5127 omega=3.72291 phi=-0.279323 -> vn=307.408 ; final sep -23.4733 ecc -1 (random count 0) - Runaway v=(-260.125,-168.966,48.5359) |v|=313.959 : companion v=(-7.80471,-0.205277,0.0209149), |v|=7.80744 ; \n", " 7.5285 3.966 7.612 BH HeHG -23.473 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", " 7.5285 3.966 7.612 BH HeHG -23.473 -1 -1.00 0.000 0.000 \"DISRUPT \"\n", " 7.5285 3.966 7.612 BH HeHG -23.473 -1 -1.00 0.000 0.000 \"END_SYMB\"\n", " 7.5285 3.966 7.612 BH HeHG -23.473 -1 -1.00 0.000 0.000 \"SN\"\n", " 7.5343 3.966 4.030 BH BH -23.473 -1 -1.00 0.000 0.000 Mers(5)=0.883215 - Mers(6)=0.0139536 - Mers(7)=0.79395 - Mers(8)=0.839891 \n", " 7.5343 3.966 4.030 BH BH -23.473 -1 -1.00 0.000 0.000 SN kick Ib/c (SN type 13 13, pre-explosion M=7.52657 Mc\"CO\"=5.78976 stellar_type=8 Eexp=1 foe vexp=5362.7 km/s) -> kick 1(190) vk=433.264 vr=0 omega=5.27719 phi=0.62846 -> vn=433.264 ; final sep -23.4733 ecc -1 (random count 5) - Runaway v=(224.099,-296.256,-215.136) |v|=433.264 : companion v=(-6.54885e-51,-8.09379e-104,-2.38777e-104), |v|=6.54885e-51 ; \n", " 7.5343 3.966 4.030 BH BH -23.473 -1 -1.00 0.000 0.000 \"TYPE_CHNGE\"\n", " 7.5343 3.966 4.030 BH BH -23.473 -1 -1.00 0.000 0.000 \"SN\"\n", " 15000.0000 3.966 4.030 BH BH -23.473 -1 -1.00 0.000 0.000 \"MAX_TIME\"\n", "\n" ] } ], "source": [ "# run via run_system\n", "output = run_system(M_1=60, \n", " M_2=40,\n", " orbital_period=2000, # days\n", " BH_prescription='BH_BELCZYNSKI',\n", " log_filename=log_filename, \n", " wind_mass_loss='WIND_ALGORITHM_BINARY_C_2020',\n", " clean_log='True', # removes log formatting \n", " log_period_unit='day', # sets the orbital periods in the log output to days\n", " api_log_filename_prefix=TMP_DIR)\n", "\n", "# Readout contents\n", "with open(log_filename, 'r') as f:\n", " print(f.read())" ] }, { "cell_type": "markdown", "id": "abdb4342-5d19-4b3f-a50b-a66abd22e8a5", "metadata": {}, "source": [ "It would be great if we can automatically detect if a system becomes a BH-BH system. We can do this with the event based logging. One of the events that is available is the `DCO_formation`, which stands for 'double compact-object formation'. If this event is present in the output then we know a compact object of some sort was formed. If we then extract the correct parameters we can find out if there is a BHBH system.\n", "\n", "Lets set up a population object and configure it. We then want to use the evolve_single function to run the systems." ] }, { "cell_type": "code", "execution_count": 4, "id": "9bea8e1d-cd96-4c14-a83b-aa667276b663", "metadata": {}, "outputs": [], "source": [ "BHBH_pop = Population(verbosity=VERBOSITY, tmp_dir=TMP_DIR)\n", "\n", "# binary-c options related to event-based logging\n", "BHBH_pop.set(\n", " event_based_logging_RLOF=1,\n", " event_based_logging_DCO=1,\n", ")\n", "\n", "# Configure system\n", "BHBH_pop.set(\n", " M_1=60, \n", " M_2=40,\n", " orbital_period=2000, # days\n", " BH_prescription='BH_BELCZYNSKI',\n", " log_filename=log_filename, \n", " wind_mass_loss='WIND_ALGORITHM_BINARY_C_2020',\n", " clean_log='True', # removes log formatting \n", " log_period_unit='day', # sets the orbital periods in the log output to days\n", ")" ] }, { "cell_type": "code", "execution_count": 5, "id": "049f8e5e-7cf9-4ece-a0b2-c0f9dbf6a28c", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'SINGLE_STAR_LIFETIME 60 7.52846\\nEVENT C02240E9-6E49-4938-9E9D-9C1DEE09400B 1 0 DCO_formation 60 40 2000 3101.19 0 7.534313670863e+00 0.02 58237 14 14 3.96639 4.03029 -4.47113 -1 106.889 -4.47113 -1 106.889 7.53431e+06 4.69096e+08 4.7663e+08 0 0 0\\n'" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "BHBH_pop.evolve_single()" ] }, { "cell_type": "markdown", "id": "f3503085-e3b2-4aaa-9d49-766a721dbf0a", "metadata": {}, "source": [ "The formatting of this output is not ideal, so lets write a functions to extract the events and parse the info. We can use the event header dictionaries to parse the events properly." ] }, { "cell_type": "code", "execution_count": 6, "id": "e3a4bfcf-620f-4132-aa8e-251ab97e15c2", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "BHBH system is unbound\n" ] } ], "source": [ "event_based_logging_parameter_list_dict = BHBH_pop.population_options['event_based_logging_parameter_list_dict']\n", "\n", "def recast_values(event_dict):\n", " \"\"\"\n", " Function to recast the values from strings to number values\n", " \"\"\"\n", " \n", " for key in event_dict.keys():\n", " if key in ['uuid', 'event_type']:\n", " continue\n", "\n", " try:\n", " if '.' in event_dict[key]:\n", " event_dict[key] = float(event_dict[key])\n", " else:\n", " event_dict[key] = int(event_dict[key])\n", " except:\n", " event_dict[key] = float(event_dict[key])\n", " \n", " return event_dict\n", "\n", "def parse_output_evolution(evolution_output, parsing_dict):\n", " \"\"\"\n", " Function to parse the output of the evolution of the system and create a dictionary containing the \n", " \"\"\"\n", " \n", " events_list = []\n", " \n", " # Loop over output\n", " for line in output_lines(evolution_output):\n", " if line.startswith(\"EVENT\"):\n", " # Parse output and create dictionary\n", " parameter_values = line.split()[1:]\n", " event_type = parameter_values[EVENT_TYPE_INDEX]\n", " parameter_names = parsing_dict[event_type]\n", " event_dict = {parameter_name: parameter_value for (parameter_name, parameter_value) in zip(parameter_names, parameter_values)}\n", " \n", " # recast values\n", " event_dict = recast_values(event_dict=event_dict)\n", " \n", " #\n", " events_list.append(event_dict)\n", " \n", " return events_list\n", "\n", "def find_BHBH_formation_event(events_list):\n", " \"\"\"\n", " Function to extract a BHBH formation event from the events list\n", " \"\"\"\n", " \n", " found_BHBH_formation_event = False\n", " BHBH_formation_event = {}\n", " \n", " for event in events_list:\n", " if (event['event_type'] == \"DCO_formation\") and (event['DCO_stellar_type_1'] == 14 and event['DCO_stellar_type_2']==14):\n", " found_BHBH_formation_event = True\n", " BHBH_formation_event = event\n", " \n", " return found_BHBH_formation_event, BHBH_formation_event\n", "\n", "\n", "# Evolve\n", "evolution_output = BHBH_pop.evolve_single()\n", "\n", "# parse output\n", "events_list = parse_output_evolution(evolution_output=evolution_output, parsing_dict=event_based_logging_parameter_list_dict)\n", "\n", "# Extract BHBH formation event\n", "found_BHBH_formation_event, BHBH_formation_event = find_BHBH_formation_event(events_list=events_list)\n", "\n", "# Print info\n", "if not found_BHBH_formation_event:\n", " print(\"No BHBH formation event found\")\n", "else:\n", " if BHBH_formation_event['DCO_separation'] < 0:\n", " print(\"BHBH system is unbound\")\n", " else:\n", " print(\"BHBH system is bound\")" ] }, { "cell_type": "markdown", "id": "004d4c6c-45c5-41b8-8695-b90d955ef8c4", "metadata": {}, "source": [ "Now that we have a function to detect a BHBH system, we want to set up a search for these systems." ] }, { "cell_type": "code", "execution_count": 7, "id": "804dbb7b-1535-4fb2-8e05-7bbd9993b6fd", "metadata": { "tags": [] }, "outputs": [], "source": [ "def search_for_BHBH(BHBH_pop, maxcount, verbosity=0):\n", " \"\"\"\n", " Function to search for BHBH formation events\n", " \"\"\"\n", " \n", " #\n", " found_bound_BHBH_system = False\n", " count = 0\n", "\n", " #\n", " while found_bound_BHBH_system == False and count < maxcount:\n", " count = count + 1\n", " if verbosity: print(\"system {} / {}\".format(count,maxcount))\n", "\n", " # Evolve\n", " evolution_output = BHBH_pop.evolve_single()\n", "\n", " # parse output\n", " events_list = parse_output_evolution(evolution_output=evolution_output, parsing_dict=event_based_logging_parameter_list_dict)\n", "\n", " # Extract BHBH formation event\n", " found_BHBH_formation_event, BHBH_formation_event = find_BHBH_formation_event(events_list=events_list)\n", "\n", " # Check if we have a bound BHBH system\n", " if found_BHBH_formation_event:\n", " if BHBH_formation_event['DCO_separation'] > 0.0:\n", " print('Found bound BHBH system')\n", " found_bound_BHBH_system = True\n", " return BHBH_formation_event, events_list\n", " \n", " # If we did not find any BHBH system we return an empty dict\n", " if found_bound_BHBH_system == False:\n", " print(\"No BHBH systems found\")\n", " return {}, []" ] }, { "cell_type": "code", "execution_count": 8, "id": "8a4de472-60a8-4267-8dd5-7ff4935d20e5", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "No BHBH systems found\n", "({}, [])\n" ] } ], "source": [ "# Configure population\n", "BHBH_pop.set(\n", " M_1=60, \n", " M_2=40,\n", " BH_prescription='BH_BELCZYNSKI',\n", " orbital_period=2000, # days\n", " wind_mass_loss='WIND_ALGORITHM_BINARY_C_2020',\n", " clean_log='True', # removes log formatting \n", " log_period_unit='day', # sets the orbital periods in the log output to days\n", ")\n", "\n", "\n", "number_of_systems = 100\n", "search_result = search_for_BHBH(\n", " BHBH_pop=BHBH_pop,\n", " maxcount=number_of_systems,\n", " verbosity=VERBOSITY,\n", ")\n", "print(search_result)" ] }, { "cell_type": "markdown", "id": "5d892330-ae72-4ccb-9234-8f6285e9d81c", "metadata": {}, "source": [ "How can we help the system become a BHBH merger? We can try turning off SN kicks." ] }, { "cell_type": "code", "execution_count": 9, "id": "54b71152-5a04-4ef8-b394-92e90ae18287", "metadata": { "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Found bound BHBH system\n", "({'uuid': '74225838-9B45-4A27-AACA-92AF2508D184', 'probability': 1, 'event_number': 0, 'event_type': 'DCO_formation', 'zams_mass_1': 60, 'zams_mass_2': 40, 'zams_orbital_period': 2000, 'zams_separation': 3101.19, 'zams_eccentricity': 0, 'time': 7.534313670863, 'metallicity': 0.02, 'random_seed': 17423, 'DCO_stellar_type_1': 14, 'DCO_stellar_type_2': 14, 'DCO_mass_1': 3.96639, 'DCO_mass_2': 4.03029, 'DCO_separation': 90146.7, 'DCO_eccentricity': 0.865727, 'DCO_period': 3035.13, 'DCO_previous_separation': 17263.9, 'DCO_previous_eccentricity': 0.304709, 'DCO_previous_period': 211.84, 'DCO_formation_time_in_years': 7534310.0, 'DCO_inspiral_time_in_years': 5.46768e+23, 'DCO_merger_time_in_years': 5.46768e+23, 'DCO_total_rlof_episodes': 0, 'DCO_stable_rlof_episodes': 0, 'DCO_unstable_rlof_episodes': 0}, [{'uuid': '74225838-9B45-4A27-AACA-92AF2508D184', 'probability': 1, 'event_number': 0, 'event_type': 'DCO_formation', 'zams_mass_1': 60, 'zams_mass_2': 40, 'zams_orbital_period': 2000, 'zams_separation': 3101.19, 'zams_eccentricity': 0, 'time': 7.534313670863, 'metallicity': 0.02, 'random_seed': 17423, 'DCO_stellar_type_1': 14, 'DCO_stellar_type_2': 14, 'DCO_mass_1': 3.96639, 'DCO_mass_2': 4.03029, 'DCO_separation': 90146.7, 'DCO_eccentricity': 0.865727, 'DCO_period': 3035.13, 'DCO_previous_separation': 17263.9, 'DCO_previous_eccentricity': 0.304709, 'DCO_previous_period': 211.84, 'DCO_formation_time_in_years': 7534310.0, 'DCO_inspiral_time_in_years': 5.46768e+23, 'DCO_merger_time_in_years': 5.46768e+23, 'DCO_total_rlof_episodes': 0, 'DCO_stable_rlof_episodes': 0, 'DCO_unstable_rlof_episodes': 0}])\n" ] } ], "source": [ "# Configure population\n", "BHBH_pop.set(\n", " sn_kick_dispersion_II=0,\n", " sn_kick_dispersion_IBC=0,\n", " sn_kick_dispersion_GRB_COLLAPSAR=0,\n", ")\n", "\n", "number_of_systems = 100\n", "search_result = search_for_BHBH(\n", " BHBH_pop=BHBH_pop,\n", " maxcount=number_of_systems,\n", " verbosity=VERBOSITY,\n", ")\n", "print(search_result)" ] }, { "cell_type": "markdown", "id": "1b486051-e728-4fe1-9860-10a712181e00", "metadata": {}, "source": [ "You should now have found a BHBH system but usually they have very wide orbits. This is caused by mass loss before, and during, the supernova. \n", "\n", "We can reduce the former by setting the wind mass loss to zero. This can be done unphysically by setting wind_mass_loss=0, or you can reduce the massive-star winds by setting the metallicity to be small, e.g. $10^{-3}$. " ] }, { "cell_type": "code", "execution_count": 10, "id": "9cf99f13-56e6-4a0a-98dc-0f833b50f010", "metadata": { "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Found bound BHBH system\n", "RLOF \n", " {'uuid': '7B34580B-BA86-4364-B219-7BE72F515970', 'probability': 1, 'event_number': 0, 'event_type': 'RLOF', 'zams_mass_1': 60, 'zams_mass_2': 40, 'zams_orbital_period': 2000, 'zams_separation': 3101.19, 'zams_eccentricity': 0, 'time': 4.058557979452, 'metallicity': 0.001, 'random_seed': 36879, 'RLOF_initial_mass_accretor': 39.7575, 'RLOF_initial_mass_donor': 54.5101, 'RLOF_initial_radius_accretor': 11.3814, 'RLOF_initial_radius_donor': 1319.94, 'RLOF_initial_separation': 3246.27, 'RLOF_initial_orbital_period': 6.04091, 'RLOF_initial_stellar_type_accretor': 1, 'RLOF_initial_stellar_type_donor': 4, 'RLOF_initial_orbital_angular_momentum': 251989000.0, 'RLOF_initial_stability': 0, 'RLOF_initial_starnum_accretor': 1, 'RLOF_initial_starnum_donor': 0, 'RLOF_initial_time': 3890959.062818, 'RLOF_initial_disk': 1, 'RLOF_final_mass_accretor': 50.4535, 'RLOF_final_mass_donor': 24.9596, 'RLOF_final_radius_accretor': 10.547, 'RLOF_final_radius_donor': 1012.85, 'RLOF_final_separation': 3211.47, 'RLOF_final_orbital_period': 6.64565, 'RLOF_final_stellar_type_accretor': 1, 'RLOF_final_stellar_type_donor': 4, 'RLOF_final_orbital_angular_momentum': 162835000.0, 'RLOF_final_stability': 0, 'RLOF_final_starnum_accretor': 1, 'RLOF_final_starnum_donor': 0, 'RLOF_final_time': 4058557.979452, 'RLOF_final_disk': 0, 'RLOF_total_mass_lost': 0, 'RLOF_total_mass_accreted': 4.41063, 'RLOF_total_mass_transferred': 4.41063, 'RLOF_total_mass_lost_from_accretor': 0, 'RLOF_total_mass_lost_from_common_envelope': 0, 'RLOF_total_time_spent_masstransfer': 167590, 'RLOF_episode_number': 1} \n", "\n", "\n", "RLOF \n", " {'uuid': '7B34580B-BA86-4364-B219-7BE72F515970', 'probability': 1, 'event_number': 1, 'event_type': 'RLOF', 'zams_mass_1': 60, 'zams_mass_2': 40, 'zams_orbital_period': 2000, 'zams_separation': 3101.19, 'zams_eccentricity': 0, 'time': 6.10177351634, 'metallicity': 0.001, 'random_seed': 36879, 'RLOF_initial_mass_accretor': 22.2425, 'RLOF_initial_mass_donor': 39.1412, 'RLOF_initial_radius_accretor': 9.43081e-05, 'RLOF_initial_radius_donor': 1669.7, 'RLOF_initial_separation': 3894.32, 'RLOF_initial_orbital_period': 9.83617, 'RLOF_initial_stellar_type_accretor': 14, 'RLOF_initial_stellar_type_donor': 4, 'RLOF_initial_orbital_angular_momentum': 137399000.0, 'RLOF_initial_stability': 0, 'RLOF_initial_starnum_accretor': 0, 'RLOF_initial_starnum_donor': 1, 'RLOF_initial_time': 5978661.25158, 'RLOF_initial_disk': 1, 'RLOF_final_mass_accretor': 22.2562, 'RLOF_final_mass_donor': 20.582, 'RLOF_final_radius_accretor': 9.43663e-05, 'RLOF_final_radius_donor': 1683.78, 'RLOF_final_separation': 4541.55, 'RLOF_final_orbital_period': 14.8282, 'RLOF_final_stellar_type_accretor': 14, 'RLOF_final_stellar_type_donor': 4, 'RLOF_final_orbital_angular_momentum': 93459900.0, 'RLOF_final_stability': 0, 'RLOF_final_starnum_accretor': 0, 'RLOF_final_starnum_donor': 1, 'RLOF_final_time': 6101773.51634, 'RLOF_final_disk': 0, 'RLOF_total_mass_lost': -2.89615, 'RLOF_total_mass_accreted': 0.0923439, 'RLOF_total_mass_transferred': 0.0923439, 'RLOF_total_mass_lost_from_accretor': -2.89615, 'RLOF_total_mass_lost_from_common_envelope': 0, 'RLOF_total_time_spent_masstransfer': 123101, 'RLOF_episode_number': 2} \n", "\n", "\n", "DCO_formation \n", " {'uuid': '7B34580B-BA86-4364-B219-7BE72F515970', 'probability': 1, 'event_number': 2, 'event_type': 'DCO_formation', 'zams_mass_1': 60, 'zams_mass_2': 40, 'zams_orbital_period': 2000, 'zams_separation': 3101.19, 'zams_eccentricity': 0, 'time': 6.337299289051, 'metallicity': 0.001, 'random_seed': 36879, 'DCO_stellar_type_1': 14, 'DCO_stellar_type_2': 14, 'DCO_mass_1': 22.2564, 'DCO_mass_2': 19.9264, 'DCO_separation': 4597.19, 'DCO_eccentricity': 0, 'DCO_period': 15.2187, 'DCO_previous_separation': 4597.17, 'DCO_previous_eccentricity': 0, 'DCO_previous_period': 15.2186, 'DCO_formation_time_in_years': 6337300.0, 'DCO_inspiral_time_in_years': 3.58246e+18, 'DCO_merger_time_in_years': 3.58246e+18, 'DCO_total_rlof_episodes': 2, 'DCO_stable_rlof_episodes': 2, 'DCO_unstable_rlof_episodes': 0} \n", "\n", "\n" ] } ], "source": [ "BHBH_pop.set(\n", " metallicity=0.001,\n", ")\n", "\n", "number_of_systems = 100\n", "BHBH_formation_event, events_list = search_for_BHBH(\n", " BHBH_pop=BHBH_pop,\n", " maxcount=number_of_systems,\n", " verbosity=VERBOSITY,\n", ")\n", "\n", "for event in events_list:\n", " print(event['event_type'], \"\\n\", event, \"\\n\\n\")" ] }, { "cell_type": "markdown", "id": "078b7220-785b-49b5-8028-d576abd6436e", "metadata": {}, "source": [ "Oh dear! While the mass loss is reduced, there is now Roche-lobe overflow (RLOF) in the system. Two stable RLOF episodes even!\n", "\n", "The first two events in the events_list are RLOF event types. The first RLOF event is RLOF from the primary (`'RLOF_initial_starnum_donor': 0`) to the secondary `'RLOF_initial_starnum_accretor': 1`).\n", "\n", "This increases the secondary's mass (`'RLOF_initial_mass_accretor': 39.7575` and `'RLOF_final_mass_accretor': 50.4535,`)\n", "\n", "\n", "We can try making the system wider to prevent this, but we want a shorter period! Instead, let's shorten the initial period to force common-envelope evolution. This will shrink the system. We will also turn off the mass loss to give us the best change of acquiring the system we want, and turn the SN kicks back on (they have less effect in closer, more gravitationally-bound systems). " ] }, { "cell_type": "code", "execution_count": 11, "id": "34bc1ffb-772f-4320-96f6-17acdaf74367", "metadata": { "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Found bound BHBH system\n", "RLOF \n", " {'uuid': 'A4E35A70-0A50-485E-954D-82264F485D96', 'probability': 1, 'event_number': 0, 'event_type': 'RLOF', 'zams_mass_1': 60, 'zams_mass_2': 40, 'zams_orbital_period': 2, 'zams_separation': 31.0119, 'zams_eccentricity': 0, 'time': 3.918234836492, 'metallicity': 0.0001, 'random_seed': 4892, 'RLOF_initial_mass_accretor': 40, 'RLOF_initial_mass_donor': 60, 'RLOF_initial_radius_accretor': 7.88211, 'RLOF_initial_radius_donor': 12.5742, 'RLOF_initial_separation': 30.3393, 'RLOF_initial_orbital_period': 0.00529926, 'RLOF_initial_stellar_type_accretor': 1, 'RLOF_initial_stellar_type_donor': 1, 'RLOF_initial_orbital_angular_momentum': 26193100.0, 'RLOF_initial_stability': 0, 'RLOF_initial_starnum_accretor': 1, 'RLOF_initial_starnum_donor': 0, 'RLOF_initial_time': 2895212.520129, 'RLOF_initial_disk': 0, 'RLOF_final_mass_accretor': 77.16, 'RLOF_final_mass_donor': 22.84, 'RLOF_final_radius_accretor': 9.6474, 'RLOF_final_radius_donor': 12.9501, 'RLOF_final_separation': 52.9579, 'RLOF_final_orbital_period': 0.0122209, 'RLOF_final_stellar_type_accretor': 1, 'RLOF_final_stellar_type_donor': 4, 'RLOF_final_orbital_angular_momentum': 25411300.0, 'RLOF_final_stability': 0, 'RLOF_final_starnum_accretor': 1, 'RLOF_final_starnum_donor': 0, 'RLOF_final_time': 3918234.836492, 'RLOF_final_disk': 0, 'RLOF_total_mass_lost': 0, 'RLOF_total_mass_accreted': 37.16, 'RLOF_total_mass_transferred': 37.16, 'RLOF_total_mass_lost_from_accretor': 0, 'RLOF_total_mass_lost_from_common_envelope': 0, 'RLOF_total_time_spent_masstransfer': 1021860.0, 'RLOF_episode_number': 1} \n", "\n", "\n", "RLOF \n", " {'uuid': 'A4E35A70-0A50-485E-954D-82264F485D96', 'probability': 1, 'event_number': 1, 'event_type': 'RLOF', 'zams_mass_1': 60, 'zams_mass_2': 40, 'zams_orbital_period': 2, 'zams_separation': 31.0119, 'zams_eccentricity': 0, 'time': 6.047398220502, 'metallicity': 0.0001, 'random_seed': 4892, 'RLOF_initial_mass_accretor': 22.8955, 'RLOF_initial_mass_donor': 75.2163, 'RLOF_initial_radius_accretor': 9.70767e-05, 'RLOF_initial_radius_donor': 203.37, 'RLOF_initial_separation': 35.0383, 'RLOF_initial_orbital_period': 0.00663959, 'RLOF_initial_stellar_type_accretor': 14, 'RLOF_initial_stellar_type_donor': 4, 'RLOF_initial_orbital_angular_momentum': 20392800.0, 'RLOF_initial_stability': 3, 'RLOF_initial_starnum_accretor': 0, 'RLOF_initial_starnum_donor': 1, 'RLOF_initial_time': 6044477.100382, 'RLOF_initial_disk': 1, 'RLOF_final_mass_accretor': 22.8955, 'RLOF_final_mass_donor': 31.9069, 'RLOF_final_radius_accretor': 9.70767e-05, 'RLOF_final_radius_donor': 1.90098, 'RLOF_final_separation': 8.56607, 'RLOF_final_orbital_period': 0.00107394, 'RLOF_final_stellar_type_accretor': 14, 'RLOF_final_stellar_type_donor': 7, 'RLOF_final_orbital_angular_momentum': 5722660.0, 'RLOF_final_stability': 3, 'RLOF_final_starnum_accretor': 0, 'RLOF_final_starnum_donor': 1, 'RLOF_final_time': 6047398.220502, 'RLOF_final_disk': 0, 'RLOF_total_mass_lost': 41.4211, 'RLOF_total_mass_accreted': 1.94368, 'RLOF_total_mass_transferred': 45.2531, 'RLOF_total_mass_lost_from_accretor': -1.88822, 'RLOF_total_mass_lost_from_common_envelope': 43.3094, 'RLOF_total_time_spent_masstransfer': 637470, 'RLOF_episode_number': 3} \n", "\n", "\n", "DCO_formation \n", " {'uuid': 'A4E35A70-0A50-485E-954D-82264F485D96', 'probability': 1, 'event_number': 2, 'event_type': 'DCO_formation', 'zams_mass_1': 60, 'zams_mass_2': 40, 'zams_orbital_period': 2, 'zams_separation': 31.0119, 'zams_eccentricity': 0, 'time': 6.375786951085, 'metallicity': 0.0001, 'random_seed': 4892, 'DCO_stellar_type_1': 14, 'DCO_stellar_type_2': 14, 'DCO_mass_1': 22.8955, 'DCO_mass_2': 31.9069, 'DCO_separation': 16.5045, 'DCO_eccentricity': 0.494521, 'DCO_period': 0.00287219, 'DCO_previous_separation': 8.34723, 'DCO_previous_eccentricity': 1.41494e-06, 'DCO_previous_period': 0.00103305, 'DCO_formation_time_in_years': 6375790.0, 'DCO_inspiral_time_in_years': 95795100.0, 'DCO_merger_time_in_years': 102171000.0, 'DCO_total_rlof_episodes': 3, 'DCO_stable_rlof_episodes': 2, 'DCO_unstable_rlof_episodes': 1} \n", "\n", "\n" ] } ], "source": [ "BHBH_pop.set(\n", " metallicity=0.0001,\n", " orbital_period=2, # days \n", " wind_mass_loss='WIND_ALGORITHM_NONE',\n", " alpha_ce = 1,\n", " lambda_ce = 0.5,\n", " sn_kick_dispersion_II=190,\n", " sn_kick_dispersion_IBC=190,\n", " sn_kick_dispersion_GRB_COLLAPSAR=190\n", ")\n", "\n", "number_of_systems = 10\n", "BHBH_formation_event, events_list = search_for_BHBH(\n", " BHBH_pop=BHBH_pop,\n", " maxcount=number_of_systems,\n", " verbosity=VERBOSITY,\n", ")\n", "\n", "for event in events_list:\n", " print(event['event_type'], \"\\n\", event, \"\\n\\n\")" ] }, { "cell_type": "markdown", "id": "b1d6cd84-0594-4636-90d6-3de599f16a1e", "metadata": {}, "source": [ "Note that this system has a far shorter period. Let's run a number of these to see what we find.\n", "\n", "Lets now try to find a system which at the formation of the final black hole has a separation of 30 $R_{\\odot}$ or less" ] }, { "cell_type": "code", "execution_count": 12, "id": "d574ce56-59a6-4267-8cc5-834a0cee9da0", "metadata": { "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Found bound BHBH system\n", "{\n", " \"uuid\": \"145CDED3-2593-4483-BEB8-D1A1BE5D9018\",\n", " \"probability\": 1,\n", " \"event_number\": 2,\n", " \"event_type\": \"DCO_formation\",\n", " \"zams_mass_1\": 60,\n", " \"zams_mass_2\": 40,\n", " \"zams_orbital_period\": 2,\n", " \"zams_separation\": 31.0119,\n", " \"zams_eccentricity\": 0,\n", " \"time\": 6.370900869438,\n", " \"metallicity\": 0.0001,\n", " \"random_seed\": 22112,\n", " \"DCO_stellar_type_1\": 14,\n", " \"DCO_stellar_type_2\": 14,\n", " \"DCO_mass_1\": 22.8401,\n", " \"DCO_mass_2\": 32.5402,\n", " \"DCO_separation\": 7.0094,\n", " \"DCO_eccentricity\": 0.40487,\n", " \"DCO_period\": 0.000790771,\n", " \"DCO_previous_separation\": 9.84471,\n", " \"DCO_previous_eccentricity\": 6.5446e-06,\n", " \"DCO_previous_period\": 0.00131624,\n", " \"DCO_formation_time_in_years\": 6370900.0,\n", " \"DCO_inspiral_time_in_years\": 4414940.0,\n", " \"DCO_merger_time_in_years\": 10785800.0,\n", " \"DCO_total_rlof_episodes\": 3,\n", " \"DCO_stable_rlof_episodes\": 2,\n", " \"DCO_unstable_rlof_episodes\": 1\n", "}\n" ] } ], "source": [ "found = False\n", "while found == False:\n", " number_of_systems = 10\n", " BHBH_formation_event, events_list = search_for_BHBH(\n", " BHBH_pop=BHBH_pop,\n", " maxcount=number_of_systems,\n", " verbosity=VERBOSITY,\n", " )\n", "\n", " if events_list and BHBH_formation_event['DCO_separation'] < 30:\n", " found = True\n", " \n", " print(json.dumps(BHBH_formation_event, indent=4))" ] }, { "cell_type": "markdown", "id": "342462a3-1c88-40d2-b217-7bd5d0976a3d", "metadata": {}, "source": [ "Playing around with the input for an individual system gives us some understanding of which parameters affect the formation of black hole systems, but, as mentioned in the introduction, this is not the most appropriate way to find many such systems. We want to make use of the Population utilities, and set up custom logging and a parse function.\n", "\n", "Things to try next:\n", "\n", "* Set up a population object and set up sampling in M1, q and orbital period (e.g. 10 x 10 x 10)\n", "* Evolve this population at various metallicities\n", "* Capture all the BHBH DCO_formation events\n", "* Do you see a trend?\n" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.9" } }, "nbformat": 4, "nbformat_minor": 5 }